﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="PowershellScript.cs" company="Collaboris Ltd.">
//   Copyright (c) Collaboris Ltd. All rights Reserved.
// </copyright>
// <summary>
//   Collates information about the name of the Powershell CmdLet
//   and the parameters that will be passed to it.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace Collaboris.Saf.Actions.Entities
{
    using System;
    using System.Collections.Generic;

    using SharePoint.Wss.Attributes;
    using SharePoint.Wss.Entities;

    [Serializable]
    [CollaborisClass(
     Title = "PowerShell Script",
     ReleaseStatus = ReleaseStatus.Stable,
     DisableDocumentation = false,
     ContactAuthorEmail = "Support@Collaboris.co.uk",
     Summary = "This class defines the settings to run a Powerscript script from Saf."
   )]
    public class PowershellScript : WSSEntityBase
    {
        /// <summary>
        /// the url of the site to process the file upon
        /// </summary>
        private List<string> commands;

        private string verbosePreference;

        private string debugPreference;

        private string errorActionPreference;

        private string shouldProcessPreference;

        private string processReturnPreference;

        private string scriptFile;

        [CollaborisProperty(
         Summary = "Specifies Verbos Preference",
         Title = "Verbose Preference",
         Example = "SilentlyContinue",
         Remarks = "Supply : SilentlyContinue, Stop, Continue and Inquire" 
         )]
        public string VerbosePreference
        {
            get
            {
                return this.verbosePreference;
            }
            set
            {
                this.verbosePreference = value;
            }
        }

        [CollaborisProperty(
         Summary = "Specifies Debug Preference",
         Title = "Debug Preference",
         Example = "SilentlyContinue",
         Remarks = "Supply : SilentlyContinue, Stop, Continue and Inquire" 
         )]
        public string DebugPreference
        {
            get
            {
                return this.debugPreference;
            }
            set
            {
                this.debugPreference = value;
            }
        }

        [CollaborisProperty(
         Summary = "Specfies Error Action Preference",
         Title = "Error Action Preference",
         Example = "SilentlyContinue",
         Remarks = "Supply : SilentlyContinue, Stop, Continue and Inquire" 
         )]
        public string ErrorActionPreference
        {
            get
            {
                return this.errorActionPreference;
            }
            set
            {
                this.errorActionPreference = value;
            }
        }

        [CollaborisProperty(
         Summary = "Should Process Preference",
         Title = "Should Process Preference",
         Example = "SilentlyContinue",
         Remarks = "Supply : SilentlyContinue, Stop, Continue and Inquire" 
         )]
        public string ShouldProcessPreference
        {
            get
            {
                return this.shouldProcessPreference;
            }
            set
            {
                this.shouldProcessPreference = value;
            }
        }

        public string ProcessReturnPreference
        {
            get
            {
                return this.processReturnPreference;
            }
            set
            {
                this.processReturnPreference = value;
            }
        }

        [CollaborisProperty(
             Summary = "Script File",
             Title = "Powershell Script File",
             Remarks = @"The full path to a Powershell Script file. e.g. C:\Temp\SomePower.ps"
         )]
        public string ScriptFile
        {
            get
            {
                return this.scriptFile;
            }
            set
            {
                this.scriptFile = value;
            }
        }

        [CollaborisProperty(
         Summary = "Script Text",
         Title = "Powershell Script Text",
         Example = "stop-process -name notepad",
         Remarks = "Dont't forget Saf can resolve placeholder's in this script text. If a 'ScriptFile' is supplied, this Script is ignored."
         )]
        public string ScriptText
        {
            get
            {
                return this.script;
            }

            set
            {
                this.script = value;
            }
        }

        [CollaborisProperty(
         Summary = "Specifies a list of Powerhsell commands to run.",
         Title = "List of Powershell Commands",
         Remarks = "To use this action Powershell needs to be resident on the target machine.",
         Required = true,
         Example = @"<list element-type=""string"">" +
                   @" <value>stop-process -name notepad</value>" +
                   @" <value>stop-process -id 6464 -confirm -passthru</value>" +
                   @"</list>",
         SerializedExample = @"<ArrayOfString type=""System.Collections.Generic.List`1[[System.String]]"">" + 
                         @" <string>stop-process -name notepad</string>" +
                         @" <string>stop-process -id 6464 -confirm -passthru</string>" +
                         @"</ArrayOfString>"
         )]
        public List<string> Commands
        {
            get
            {
                return this.commands;
            }
            set
            {
                this.commands = value;
            }
        }

        private string script;
    }
}